<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" 
      xmlns:ui="http://java.sun.com/jsf/facelets" 
      xmlns:h="http://java.sun.com/jsf/html" 
      xmlns:f="http://java.sun.com/jsf/core">
	<f:view locale="#{languageBean.locale}">
	    <h:head>
	    	<title>KeeBook</title>
	    	<link rel="stylesheet" type="text/css" href="css/keebook.css" />
	    	<!--[if lte IE 8]><link rel="stylesheet" type="text/css" href="css/ie8.css"><![endif]-->
	    	<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;" />
	    	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	    </h:head>
	    <h:body>
	    	<div id="layer"></div>
	    	<div id="isMobile"></div>
	    	<div id="loading">
	    		<img src="images/indicator.gif" alt="" />
	    		<h:outputText value="#{i18n['generic.loading']}" />
	    	</div>
	    	<div id="contentContainer">
		    	<div id="head">
		    		<ui:fragment rendered="#{sessionBean.loggedIn}">
		    			<h:form><h:commandLink id="logout" title="#{i18n['generic.logout']}" styleClass="logoutIcon" action="#{loginBean.logout}" onclick="logout()" value="Log out" /></h:form>
		    			<a id="settingsIcon" href="settings.xhtml">Settings</a>
		    		</ui:fragment>
		    		<a href="./"><img src="images/keebook.png" alt="KeeBook" id="logo" /></a>
		    	</div>
		    	<ui:include src="./tabhint.xhtml" />
		    	<ui:fragment rendered="#{searchHeader eq true}">
		   			<h:form id="searchHeader">
		   				<div id="topButtonsContainer">
			   				<div id="bookDropdown" class="dropdown-menu">
			   					<span><h:outputText value="#{sessionBean.keeBook.name}" /></span><img src="images/keedown.png" alt="" />
			   					<ul>
			   						<ui:fragment rendered="#{sessionBean.getKeeBookAccess('OWNER')}">
			   							<li><a href="listshares.xhtml"><h:outputText value="#{i18n['framework.sharingSettings']}" /></a></li>
			   						</ui:fragment>
			   						<ui:fragment rendered="#{sessionBean.getKeeBookAccess('READ_WRITE')}">
			   							<ui:fragment rendered="#{listEntriesBean.hasGroups}">
			   								<li><a href="listgroups.xhtml"><h:outputText value="#{i18n['framework.manageGroups']}" /></a></li>
			   							</ui:fragment>
			   							<li><a href="import.xhtml"><h:outputText value="#{i18n['framework.import']}" /></a></li>
			   						</ui:fragment>
			   						<li><a href="export.xhtml"><h:outputText value="#{i18n['framework.export']}" /></a></li>
			   						<ui:fragment rendered="#{sessionBean.getKeeBookAccess('OWNER')}">
			   							<li><a href="renamekeebook.xhtml"><h:outputText value="#{i18n['framework.modifyBook']}" /></a></li>
			   						</ui:fragment>
			   						<li><a href="selectkeebook.xhtml"><h:outputText value="#{i18n['framework.switchBook']}" /></a></li>
			   					</ul>
			   				</div>
			   				<ui:fragment rendered="#{sessionBean.getKeeBookAccess('READ_WRITE')}">
			   					<div class="button" id="addEntryButton" onclick="location.href='add.xhtml'"><h:outputText value="#{i18n['framework.addEntry']}" /></div>
			   				</ui:fragment>
		   				</div>
		   				<div id="searchFieldContainer">
							<h:inputText id="s" value="#{listEntriesBean.searchKeyword}" autocomplete="off" />
							<img src="images/clear.png" alt="" id="clearSearch" />
						</div>
						<h:commandButton action="#{listEntriesBean.search}" style="display:none" />
					</h:form>
					<script type="text/javascript">
						var fieldInformation = {
							s: {placeholder: "#{i18n['framework.searchPlaceholder']}"}
						};
					</script>
					<ui:include src="./message.xhtml" />
		    	</ui:fragment>
		    	
		    	<div id="content" class="#{noContentMargin ne true ? '' : 'noMargin'}">
		    		<ui:insert name="content">Content missing...</ui:insert>
		    		<f:loadBundle basename="revision" var="revision"/>
		    		<div id="footer">
		    			&#169; KeeBook.net.
		    			Revision: <h:outputText value="#{revision.revision}"/>
			    		<h:form style="float:right;margin-left:20px">
			    			<h:commandLink action="#{languageBean.setLocaleCode('de', 'DE')}"><img src="images/de.png" class="country" alt="de" /></h:commandLink>
			    			<h:commandLink action="#{languageBean.setLocaleCode('en', 'US')}"><img src="images/us.png" class="country" alt="en" /></h:commandLink>
		    			</h:form>
		    		</div>
		    	</div>
	    	</div>
	    	<script type="text/javascript">
	    		var isLoggedIn = #{sessionBean.loggedIn ? 'true' : 'false'};
				function downloadJSAtOnload() {
					var element = document.createElement("script");
					element.type = 'text/javascript';
					element.src = "js/keebook-#{revision.revision}.js?rebuild=1";
					document.body.appendChild(element);
				}
				if (window.addEventListener)
					window.addEventListener("load", downloadJSAtOnload, false);
				else if (window.attachEvent)
					window.attachEvent("onload", downloadJSAtOnload);
				else window.onload = downloadJSAtOnload;
			</script>
	    </h:body>
    </f:view>
</html>